import http from "./http";

export const uploadFile = async (file: File, file_type: string) => {
  const formData = new FormData();
  formData.append("file", file);
  formData.append("file_type", file_type);
  return await http.post("/files/upload", formData);
}

export const returnFileUrl = (url: string) => {
    const baseURL = import.meta.env.VITE_API_URL;
    const [sub_folder, fileid] = url.split("/");
    return  `${baseURL}/files/getfile/${fileid}?sub_folder=${sub_folder}`;
};

